/**
 * @file simple_widget.h
 * @author ThomasKingFree (dulu150@126.com)
 * @brief
 * @version 0.1
 * @date 2021-03-21
 *
 * @copyright Copyright (c) 2021
 *
 */

#ifndef YUE_GUI_SIMPLE_WIDGET_H
#define YUE_GUI_SIMPLE_WIDGET_H

#include "utils/geometry.h"
#include "utils/rect.h"

namespace YueGUI {
class SimpleWidget {
public:
    SimpleWidget();
    ~SimpleWidget();

    /**
     * @brief 控件渲染入口
     *
     * 检查控件布局是否需要重绘,如果需要重绘则调用OnDraw
     *
     * @param dirty 重绘区域
     */
    virtual void Draw(const Rect &dirty);

    /**
     * @brief 控件真正的渲染逻辑实现
     *
     * 调用光栅化层提供的接口,渲染出来目标效果
     *
     * @param dirty
     */
    virtual void OnDraw(const Rect &dirty);

private:
    Rect rect_ = {Geometry::INVALID_COORD, Geometry::INVALID_COORD,
                  Geometry::INVALID_WIDTH, Geometry::INVALID_HEIGHT};
};
} // namespace YueGUI
#endif // YUE_GUI_SIMPLE_WIDGET_H
